package com.ejlchina.tool.fragment

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.LinearLayoutManager
import com.adolf.androiddemo.R
import com.adolf.androiddemo.databinding.LayoutBottomSheetListBinding
import com.ejlchina.tool.adapter.BottomSheetListAdapter
import com.ejlchina.tool.util.showToast
import com.google.android.material.bottomsheet.BottomSheetDialogFragment

class AntiPinchBottomSheetDialog: BottomSheetDialogFragment() {
    private lateinit var binding: LayoutBottomSheetListBinding
    private lateinit var bottomSheetListAdapter: BottomSheetListAdapter

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setStyle(STYLE_NORMAL, R.style.StyleBottomSheetStyleWrapper)
    }

    override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
        binding = LayoutBottomSheetListBinding.inflate(inflater,container,false)
        return binding.root
    }

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        initData()
    }

    private fun initData(){
        val intentData = listOf("1","2","3")
        bottomSheetListAdapter = BottomSheetListAdapter(intentData){ position, value ->
            showToast("点击了$position,value is $value")
        }
        binding.rvData.apply {
            adapter = bottomSheetListAdapter
            layoutManager = LinearLayoutManager(requireContext())
        }
    }
}